<?php
//use Illuminate\Support\Facades\Schema;
use Jialeo\LaravelSchemaExtend\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAuthsTable extends Migration
{
	/**
	 *所需命令行
	 *1.创建迁移文件：php artisan module:make-migration  create_auths_table Admin
	 *php artisan make:migration add_images_to_articles_table --table=articles
	 *2.执行迁移文件：php artisan module:migrate Admin
	 *3.修改表字段：php artisan module:make-migration update_moments_table
	 *4.重新执行迁移文件：php artisan module:migrate-refresh Admin 
	 *5.创建数据填充文件：php artisan module:make-seed  auths_table_seeder Admin
	 *6.执行数据填充文件：php artisan module:seed Admin
	 */
    public function up()
    {
		/**
		 * 管理员表
		 */
        Schema::create('admins', function (Blueprint $table) {
			$table->comment = '管理员表';
            $table->increments('id')->comment('管理员ID');
            $table->string('username',50)->unique()->default('')->comment('账号');
            $table->string('password')->default('')->comment('密码');
            $table->integer('group_id')->nullable()->comment('权限组ID');
            $table->tinyInteger('status')->default(1)->comment('审核状态:0=禁用,1=启用');
            $table->rememberToken();
            $table->uuid('uuid');
            $table->timestamps(); 
        });

		/**
		 * 权限组表
		 */
        Schema::create('auth_groups', function (Blueprint $table) {
			$table->comment = '权限组表';
            $table->increments('id')->comment('权限组ID');
            $table->string('title',100)->unique()->default('')->comment('权限名称');
            $table->tinyInteger('status')->default(1)->comment('状态:0=禁用,1=启用');
			$table->longtext('rules')->nullable()->comment('权限规则多个用|隔开');
            $table->timestamps();
        });
		/**
		 * 权限列表
		 */
        Schema::create('auth_rules', function (Blueprint $table) {
			$table->comment = '权限表';
            $table->increments('id')->comment('权限列表ID');
            $table->string('href',100)->default('')->comment('路由地址');
            $table->string('title',100)->default('')->comment('中文名称');
			$table->tinyInteger('status')->default(1)->comment('侧边栏显示状态:0=隐藏,1=显示');
			$table->tinyInteger('auth_open')->default(1)->comment('是否验证权限:0=否,1=是');
			$table->string('icon',50)->nullable()->comment('图标');
			$table->integer('pid')->default(0)->comment('父级ID');
			$table->integer('sort')->default(1)->comment('排序');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admins');
		Schema::dropIfExists('auth_groups');
		Schema::dropIfExists('auth_rules');
    }
}
